#!/bin/bash  

function rand(){ 
 min=$1 
 max=$(($2-$min+1)) 
 num=$(($RANDOM+1000000000)) #增加一个10位的数再求余 
 echo $(($num%$max+$min)) 
}  
rnd=$(rand 40000 50000) 
echo $rnd 
#      listen 40733 reuseport;
#      listen [::]:40733 reuseport;
sed -i 's/listen [1-9].... reuseport/listen '"$rnd"' reuseport/g' /var/local/nginx/conf/nginx.conf
sed -i 's/listen \[::\]:[1-9].... reuseport/listen [::]:'"$rnd"' reuseport/g' /var/local/nginx/conf/nginx.conf

docker rm -f mynginx
docker run  -d --restart=always --name mynginx  --network host -v /etc/v2ray-agent/tls/:/etc/v2ray-agent/tls/ -v /var/local/nginx/conf/nginx.conf:/etc/nginx/nginx.conf  -v /var/local/nginx/logs:/var/log/nginx  -v /var/local/web/love1:/usr/share/nginx/html nginx
echo '重启完成'